start, end = input().split('-')
start_h, start_m = map(int, start.split(':'))
end_h, end_m = map(int, end.split(':'))
minutes = (end_h * 60 + end_m - start_h * 60 - start_m) % 1440
extra = max(minutes - 30, 0)
fee = ((extra + 29) // 30) * 1.5
print("{0:.1f}".format(fee))